home *** CD-ROM | disk | FTP | other *** search
- Path: newspost1.alt.net!usenet
- From: walth@netcom.com (Walt Howard)
- Newsgroups: comp.lang.c++
- Subject: Re: weird behavior
- Date: Sun, 28 Jan 1996 12:25:23 GMT
- Organization: AltNet - Affordable Usenet Access - http://www.alt.net
- Message-ID: <4efpvs$elb@tofu.alt.net>
- References: <4ed10l$jap@news.csus.edu>
- Reply-To: walth@netcom.com
- X-Newsreader: Forte Agent .99c/32.126
-
- On 27 Jan 1996 11:07:01 GMT, gustavo.sandoval@csus.edu (gustavo
- sandoval) wrote:
-
- >I have the following linked list which I'm playing around with:
- >
- >class CList
- >{
- >public:
- > CList();
- > ~CList();
- >
- > void Insert(int element);
- > void Print ();
- >
- > // Returns the number or items deleted
- > int Delete(int target);
- >
- >private:
- > CItem* head;
- >
- >};// CList
- >
- >// Implementation of the functions omitted
- >
- >// In main I have:
- >
- >void main ()
- >{
- > CList MyList;
- >
- > for (int x = 0; x < 10; x++ )
- > MyList.Insert (x*10);
- >
- > MyList.Print();
- >
- > int count = MyList.Delete (40);
- >
- > MyList.Insert (50);
- > MyList.Insert; // <== this lines
- > MyList.Print; // <== this lines
- >
- > count = MyList.Delete (50);
- >
- >}
- >
- >
- >note the lines with the arrows. The code compiles in VC 4.0 without warnings
- >in level 4 or errors. When I step through those two lines the debugger just
- >goes right by.
- >
-
- Well, I should really try to compile this but it's getting later. The
- function names by themselves might be considered valid expressions
- (pointers) and then the compiler is optimizing them out because they
- aren't doing anything. But what do I know?
-
- >Also I looked at the disassembly and I have the following:
- >
- >181: MyList.Insert (50);
- >00401541 push 00000032
- >00401543 lea ecx,dword ptr [MyList]
- >00401546 call @ILT+10(?Insert@CList@@QAEXH@Z) (0040100a)
- >182: MyList.Insert;
- >183: MyList.Print;
- >184:
- >185: count = MyList.Delete (50);
- >0040154b push 00000032
- >0040154d lea ecx,dword ptr [MyList]
- >00401550 call @ILT+65(?Delete@CList@@QAEHH@Z) (00401041)
- >00401555 mov dword ptr [count],eax
- >
- >
- >It just seems that the compiler is inserting no-ops. Is this the right
- >behavior. To me this seems like a bug that the compiler is not catching, but
- >then what do I know.
- >
- >thanks in advance,
- >
- >gustavo
- >
-
-
-